#include "stm32f10x.h"
#include "Delay.h"
#include "OLED.h"
#include "Serial.h"
#include "LED.h"
#include <string.h>
//串口收发文本数据包+LED测试
uint8_t RxData;

int main(void) {
    OLED_Init();    // 初始化OLED
    Serial_Init();  // 初始化串口
		LED_Init();
		OLED_ShowString(1,1,"Serial_TxPacket:");
		OLED_ShowString(3,1,"Serial_RxPacket:");
		

    while (1) {
			if(RxFlag==1){
				//在显示之前，需要清除第4行，因为字符串长度不确定，如果一个是长的，一个是小的，那大的会露出来
					OLED_ShowString(4,1,"										");
					OLED_ShowString(4,1,Serial_RxPacket);
				//调用字符串函数，对字符串进行操作
				//判断两个字符串是否相对等
				if(strcmp(Serial_RxPacket,"LED_ON")==0){
					LED1_ON();
					Serial_SendString("LED_ON_OK\r\n");
					OLED_ShowString(2,1,"										");
					OLED_ShowString(2,1,Serial_RxPacket);
				}
				else if(strcmp(Serial_RxPacket,"LED_OFF")==0){
					LED1_OFF();
					Serial_SendString("LED_OFF_OK\r\n");
					OLED_ShowString(2,1,"										");
					OLED_ShowString(2,1,Serial_RxPacket);
				}
				else{
					Serial_SendString("Error_Command\r\n");
					OLED_ShowString(2,1,"										");
					OLED_ShowString(2,1,"Error_Command");
				}
				RxFlag=0;
			}
    }
}